package stu.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import stu.aistar.dao.ICinameDao;
import stu.aistar.dao.IMovieDao;
import stu.aistar.model.pojo.Ciname;
import stu.aistar.model.pojo.Movie;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/movies")
public class MovieCinameController {
    @Autowired
    private IMovieDao iMovieDao;
    @Autowired
    private ICinameDao iCinameDao;

    @GetMapping("/checkout")
    public String cinames(Model model, String moviename){

        Movie movies = iMovieDao.findMovieByName(moviename);

        List<Ciname> cinames = iCinameDao.findAll();

        model.addAttribute("movies",movies);

        model.addAttribute("cinames",cinames);

        return "movie-ticket-plan";
    }
}
